home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Mark Pilgrim / Dialectic 1.2 / source / Dialectic ƒ / Shell ƒ / error.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-30  |  2.2 KB  |  63 lines  |  [TEXT/KAHL]

  1. /**********************************************************************\
  2.  
  3. File:        error.c
  4.  
  5. Purpose:    This module handles altering the user when an error has
  6.             occurred.  (If the program is currently in the background,
  7.             we use the Notification Manager to queue a notification
  8.             request and display the alert as soon as we are in the
  9.             foreground -- see main.c, DispatchEvents, case osEvt.)
  10.  
  11. \**********************************************************************/
  12.  
  13. #include "error.h"
  14. #include "main.h"
  15. #include "dialogs.h"
  16. #include "environment.h"
  17. #include "program globals.h"
  18.  
  19. NMRec            gMyNotification;
  20. int                gPendingResultCode;
  21.  
  22. void HandleError(int resultCode, Boolean exitToShell)
  23. /* if we're in the foreground, just get the error string (from the .rsrc file) and
  24.    display the error alert; otherwise, we have to queue it, put up a notification
  25.    (if possible), and wait patiently to come back in the foreground.  (see main.c,
  26.    DispatchEvents(), case osEvt. */
  27. /* All error codes are listed in program globals.h */
  28. {
  29.     Str255            tempStr;
  30.     Handle            myResHand;
  31.     
  32.     /* if there is no error, or the error is that the user cancelled an operation
  33.        in progress, don't display anything; it would only confuse them. */
  34.     if ((resultCode==userCancelErr) || (resultCode==allsWell)) return;
  35.     
  36.     if (gIsInBackground)    /* if program is in background, can't display alert immed. */
  37.     {
  38.         if (gHasNotificationManager)    /* if they don't have notification, f*ck 'em */
  39.         {
  40.             myResHand=GetResource('SICN', 1234);    /* small icon for menu bar flashing */
  41.             gMyNotification.qType=nmType;            /* for more detail on these params, */
  42.             gMyNotification.nmMark=1;                /* see IM Processes, 5-8 */
  43.             gMyNotification.nmIcon=myResHand;
  44.             gMyNotification.nmSound=(Handle)-1L;
  45.             gMyNotification.nmStr=0L;
  46.             gMyNotification.nmResp=0L;
  47.             gMyNotification.nmRefCon=0L;
  48.             NMInstall(&gMyNotification);
  49.         }
  50.         gPendingResultCode=resultCode;                /* remember error code for later */
  51.     }
  52.     else
  53.     {
  54.         GetIndString(tempStr, 129, resultCode);        /* get error string from .rsrc */
  55.         ParamText(tempStr, "\p", "\p", "\p");
  56.         PositionDialog('ALRT', largeAlert);        /* position alert (see dialogs.c) */
  57.         StopAlert(largeAlert, 0L);                /* show it */
  58.     }
  59.     
  60.     if (exitToShell)        /* for fatal errors */
  61.         ExitToShell();
  62. }
  63.